package cn.zt.ztzx.controller;

import cn.zt.ztzx.domain.SysUser;
import cn.zt.ztzx.model.dto.system.LoginDto;
import cn.zt.ztzx.model.vo.common.Result;
import cn.zt.ztzx.model.vo.common.ResultCodeEnum;
import cn.zt.ztzx.model.vo.system.LoginVo;
import cn.zt.ztzx.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("admin")
@Tag(name = "首页接口", description = "首页相关")
public class IndexController {

    @Resource
    private SysUserService sysUserService;

    @GetMapping("ceshi")
    @Operation(method = "get", summary = "默认首页", description = "完成XX功能")
    @Parameters({@Parameter(name = "id", description = "用户id")})
    public Result index(String id) {
        return Result.build(id, 200, "成功");
    }

    //登录
    @PostMapping("login")
    public Result<LoginVo> login(@RequestBody LoginDto loginDto) {
        return sysUserService.login(loginDto);
    }


    //获取用户接口信息
    @GetMapping("getuserinfo")
    public Result<SysUser> getuserinfo(@RequestHeader("token")String token){
      SysUser sysUser=  sysUserService.getuserinfo(token);
      return Result.build(sysUser, ResultCodeEnum.SUCCESS);
    }

}
